package com.mzj.saas.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.dto.CalendarPriceDTO;
import com.haixiaoke.saas.repository.pojo.CalendarPrice;
import com.haixiaoke.saas.repository.service.ICalendarPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 日历价格Controller
 *
 * @author 嗨小克
 * @date 2023-05-23
 */
@RestController
@RequestMapping("/biz/calendarPrice")
public class CalendarPriceController extends BaseController {
    @Autowired
    private ICalendarPriceService calendarPriceService;

    /**
     * 查询日历价格列表
     */
    @GetMapping("/list")
    public AjaxResult list(CalendarPrice calendarPrice) {
        List<CalendarPrice> list = calendarPriceService.selectCalendarPriceList(calendarPrice);
        return success(list);
    }

    /**
     * 获取日历价格详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(calendarPriceService.selectCalendarPriceById(id));
    }

    /**
     * 新增日历价格
     */
    @PostMapping
    public AjaxResult add(@RequestBody CalendarPrice calendarPrice) {
        return toAjax(calendarPriceService.insertCalendarPrice(calendarPrice));
    }

    @PostMapping("/addBatch")
    public AjaxResult addBatch(@RequestBody CalendarPriceDTO calendarPriceDTO) {
        return toAjax(calendarPriceService.insertBatchCalendarPrice(calendarPriceDTO));
    }

    /**
     * 修改日历价格
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CalendarPrice calendarPrice) {
        return toAjax(calendarPriceService.updateCalendarPrice(calendarPrice));
    }

    /**
     * 删除日历价格
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(calendarPriceService.deleteCalendarPriceByIds(ids));
    }
}
